//
//  ViewController.m
//  AutoCreatePropertyDemo
//
//  Created by anmin on 2017/11/24.
//  Copyright © 2017年 puhui. All rights reserved.
//

//#import "TACP_TestModel.h"
//#import "TACP_ArrayDict.h"
#import "ACPCategary.h"
#import "AutoCreateProperty/AutoCreateProperty.h"
#import "ViewController.h"

@interface propertyModel : NSObject

@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *attributes;

@end

@implementation propertyModel

@end

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *label;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    //批发商
    NSString *htmlStr = @"<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\" name=\"viewport\"content=\"width=device-width, initial-scale=1, maximum-scale=1.0,user-scalable=no;\" />\n<title></title>\n</head>\n<body>\n<font font-size=\"12\" color=\"#333333\">请按要求上传如下资料：</br>1.批发商头像。</br>2.营业执照证明清晰照片。</br>3.法人身份证正反面照片。</br>4.其他资质相关证照。</font></br></br>\n<font font-size=\"11\" color=\"#999999\">批发商首次注册时可跳过上传证照的流程，注册后即可体验。如需创建店铺或上传商品，则必须完成证照的上传，审核通过后方可创建店铺和上传商品。</font>\n</body>\n</html>";
    //商户
    NSString *htmlStr2 = @"<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\" name=\"viewport\"content=\"width=device-width, initial-scale=1, maximum-scale=1.0,user-scalable=no;\" />\n<title></title>\n</head>\n<body>\n<font font-size=\"12\" color=\"#333333\">请按要求上传如下资料：</br>1.门店现场照片。</br>2.营业执照证明清晰照片。</br>3.法人身份证正反面照片。</br>4.其他资质相关证照。</font></br></br>\n<font font-size=\"11\" color=\"#999999\">商户首次注册时可跳过上传证照的流程，注册后即可体验。如需申请“先货后款额”，则必须完成证照的上传，审核通过后方提交额度申请。（额度申请所需相关资料，详见额度申请页面</font>\n</body>\n</html>";
    //转换成富文本
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    _label.attributedText = attrStr;
    return;
    NSDictionary *dict = @{
                           @"douleAbc":@3.1,
                           @"abc":@4,
                           @"id":@3,
                           @"desc":@"简单描述",
                           @"bannerArray":@[
                                   @"www.baidu.com",
                                   @"www.oschina.net",
                                   ],
                           @"imageArray":@[
                                   @{
                                       @"img":@"www.baidu.com",
                                       @"values":@[@2, @2.1, @3.3,]
                                       },
                                   ],
                           @"intValue":@2,
                           @"doubleValue":@3.3,
                           @"strArray":@[@"1111", @"2222"],
                           @"arrayStr":@[@[@"1111"], @[@"2222"]],
                           @"arrayNum":@[@[@2, @1]],
                           @"arrayDict":@[
                                   @[@{
                                         @"url":@"www.baidu.com",
                                         @"num":@3,
                                         }],
                                   ],
                           };

    [[AutoCreateProperty defaultInstance] autoGenerateModelWithModelPrefix:@"TACP_" noPrefixModelName:@"testModel" dataSource:dict complete:^(BOOL isSuccess, NSError * _Nullable error) {
        NSLog(@"AutoCreateProperty Finished %d", isSuccess);
        if (error) {
            NSLog(@"%@", error.userInfo[NSLocalizedDescriptionKey]);
        }
    }];
    
#if TARGET_IPHONE_SIMULATOR
    NSLog(@"TARGET_IPHONE_SIMULATOR");
#elif TARGET_OS_IPHONE
    NSLog(@"TARGET_OS_IPHONE");
#endif
    
//    TACP_TestModel *model = [[TACP_TestModel alloc] initWithDictionary:dict];
//    NSLog(@"%d", model.id);

//    NSString *infoPlistPath = [[NSBundle mainBundle]pathForResource:@"Info.plist" ofType:nil];
//    NSDictionary *infoDict = [NSDictionary dictionaryWithContentsOfFile: infoPlistPath];
//    NSString *modelDirPath = [infoDict[@"ModelDir"] handel_path];
//    NSString *fileName = [@"testFile" stringByAppendingString:@".h"];
//    NSString *path = [@[modelDirPath, fileName] componentsJoinedByString:@"/"];
//    NSFileManager *fm = [NSFileManager defaultManager];
//    [fm createFileAtPath:path contents:nil attributes:nil];
//
//    NSString *string = [dict jsonString];

//
//
//
//    NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
//    [data writeToFile:path atomically:YES];
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
